<template>
    <div class="template-form-Lu">
        <a-modal
            title="会务保障登记申请"
            :visible="applicationFormVisible"
            :maskClosable="false"
            :closable="true"
            :destroyOnClose="true"
            width="100%"
            :dialog-style="{ margin: '0 auto' }"
            wrapClassName="applicationModal-form-fullmodal-Lu"
            @cancel="closeVisible">
            <div class="applicationModal-div-box-Lu">
                <div class="tabs-card-edit-box">
                    <a-tabs type="card" v-model:activeKey="summaryActiveKey" @change="summaryActiveChange">
                        <a-tab-pane key="申请表" tab="申请表"></a-tab-pane>
                        <a-tab-pane key="流转记录" tab="流转记录"></a-tab-pane>
                    </a-tabs>
                </div>
                <div  class="tab-box-v1">
                    <div v-if="summaryActiveKey == '申请表'" style="width: 80%;margin: 0 auto;padding-top: 30px;padding-bottom: 30px;">
                        <a-spin :spinning="spinning">
                            <a-button class="blue-btn" @click="printClick('会议室',formState,qmImgList)" v-if="linkName == '我的已办'">打印</a-button>
                            <a-form :form="aform" ref="form" class="internalControl-reimbursement-model-form-box">
                                <a-descriptions bordered style="width: 100%;">
                                    <a-descriptions-item :span="2">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName=='申请确认' || linkName == '数据修订'">*</span>
                                            会议内容
                                        </span>
                                        <a-form-item ref="fhynr" prop="fhynr" class="zm-form-model">
                                            <a-textarea
                                                v-if="linkName=='申请确认' || linkName == '数据修订'"
                                                v-model="formState.fhynr"
                                                placeholder="请输入会议内容:"
                                                :auto-size="{ minRows: 2}"
                                                v-decorator="[
                                                    'fhynr', {initialValue:formState.fhynr,rules: rules.fhynr}]"
                                            />
                                            <span v-else>{{ formState.fhynr }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item style="width: 300px !important;">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName=='申请确认' || linkName == '数据修订'">*</span>
                                            会议地点
                                        </span>
                                        <a-form-item ref="fjbzbsc" prop="fjbzbsc" style="width: 300px !important;">
                                            <div v-if="linkName=='申请确认' || linkName == '数据修订'">
                                                <compSelector
                                                    :defaultValue="formState.fhydd"
                                                    :compType="typeSelect"
                                                    dictionaryType="会议室名称"
                                                    placeholder="请选择会议地点"
                                                    style="width:200px;display:inline-block;"
                                                    class="compSelector compSelectorHydd"
                                                    @selectHandleChange="fhyddChange"
                                                    v-decorator="[
                                                        'fhydd', {initialValue:formState.fhydd,rules: rules.fhydd}]"/>
                                                    <br/>
                                                    <a-button @click="searchUse" style="margin-right: 10px;" class="blue-btn">查询是否可用</a-button>
                                                    <a-button @click="roomXiangQing" class="blue-btn">会议室详情</a-button>
                                            </div>
                                                <span v-else>{{ formState.fhydd.toString() }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName=='申请确认' || linkName == '数据修订'">*</span>
                                            会议日期
                                        </span>
                                        <a-form-item ref="fjbzbksrq" prop="fjbzbksrq" class="zm-form-model">
                                            <a-date-picker
                                                v-if="linkName=='申请确认' || linkName == '数据修订'"
                                                v-model="timeForm.rqDate"
                                                type="date"
                                                placeholder="会议日期"
                                                v-decorator="[ 'rqDate', {initialValue:timeForm.rqDate,rules: rules.rqDate}]"/>
                                            <span v-else>{{ moment(formState.fhykssj).format('YYYY-MM-DD') }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName=='申请确认' || linkName == '数据修订'">*</span>
                                            会议开始时间
                                        </span>
                                        <a-form-item ref="fjbzbksrq" prop="fjbzbksrq" class="zm-form-model">
                                            <a-time-picker
                                                v-if="linkName=='申请确认' || linkName == '数据修订'"
                                                :default-value="timeForm.startTime"
                                                :minute-step="10"
                                                format="HH:mm"
                                                @change="startTimeChange"
                                                v-decorator="[ 'startTime', {initialValue:timeForm.startTime,rules: rules.startTime}]"
                                            />
                                            <span v-else>{{ moment(formState.fhykssj).format('HH:mm') }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName=='申请确认' || linkName == '数据修订'">*</span>
                                            会议结束时间
                                        </span>
                                        <a-form-item ref="fjbzbjsrq" prop="fjbzbjsrq" class="zm-form-model">
                                            <a-time-picker
                                                v-if="linkName=='申请确认' || linkName == '数据修订'"
                                                :default-value="timeForm.endTime"
                                                :minute-step="10"
                                                format="HH:mm"
                                                @change="endTimeChange"
                                                v-decorator="[ 'endTime', {initialValue:timeForm.endTime,rules: rules.endTime}]"
                                            />
                                            <span v-else>{{ moment(formState.fhyjssj).format('HH:mm') }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            中心领导
                                        </span>
                                        <a-form-item ref="fzxld" prop="fzxld" class="zm-form-model">
                                            <compSelector
                                                v-if="linkName=='申请确认' || linkName == '数据修订'"
                                                :key="compSelectorkey"
                                                @selectHandleChange="fzxldChange"
                                                v-model="formState.fzxld"
                                                :defaultValue="formState.fzxld"
                                                :compType="typeCheckbox"
                                                class="comp-select-box-a"
                                                dictionaryType="会议室中心领导"/>
                                            <span v-else>{{ formState.fzxld.toString() }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="2">
                                        <span slot="label" class="descriptions-label-slot">
                                            科室单位
                                        </span>
                                        <a-form-item ref="fksdw" prop="fksdw" class="zm-form-model">
                                            <compSelector
                                                v-if="linkName=='申请确认' || linkName == '数据修订'"
                                                :key="compSelectorkey"
                                                v-model="formState.fksdw"
                                                @selectHandleChange="selectHandleChange"
                                                :defaultValue="formState.fksdw"
                                                :compType="typeCheckbox"
                                                class="comp-select-box-hys-ksdw"
                                                dictionaryType="OA申请科室单位"/>
                                            <span v-else>{{ formState.fksdw.toString() }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            参会人数
                                        </span>
                                        <a-form-item ref="fjbzbsc" prop="fjbzbsc" class="zm-form-model">
                                            <a-input-number
                                                v-if="linkName =='申请确认'||linkName == '数据修订'"
                                                v-model="formState.fchry"/>
                                            <span v-else>{{ formState.fchry }} 人</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            外单位人员人数
                                        </span>
                                        <a-form-item ref="fjbzbsc" prop="fjbzbsc" class="zm-form-model">
                                            <a-input-number
                                                v-if="linkName =='申请确认'||linkName == '数据修订'"
                                                :default-value="formState.fwdwrys"
                                                v-model="formState.fwdwrys"/>
                                            <span v-else>{{ formState.fwdwrys }} 人</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            外单位人员
                                        </span>
                                        <a-form-item ref="fjbzbsc" prop="fjbzbsc" class="zm-form-model">
                                            <a-textarea
                                                v-if="linkName =='申请确认'||linkName == '数据修订'"
                                                v-model="formState.fwdwry"
                                                :defaultValue="formState.fwdwry"
                                                placeholder="请输入外单位名称或外单位人员姓名"
                                                :auto-size="{ minRows: 2}"/>
                                            <span v-else>{{ formState.fwdwry }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3">
                                        <span slot="label" class="descriptions-label-slot">
                                            工作要求
                                        </span>
                                        <a-form-item ref="fjbzbsc" prop="fjbzbsc" class="zm-form-model">
                                            <div v-if="linkName=='申请确认' || linkName == '数据修订'">
                                                <a-checkbox
                                                    v-model="formState.fsfycs">
                                                    茶水
                                                </a-checkbox >
                                                <a-checkbox
                                                    v-model="formState.fsfykqs">
                                                    矿泉水
                                                </a-checkbox >
                                                <a-checkbox
                                                    v-model="formState.fsfytq">
                                                    台签
                                                </a-checkbox >
                                                <a-checkbox
                                                    v-model="formState.fsfyyx">
                                                    音响
                                                </a-checkbox >
                                            </div>
                                            <div v-else>
                                                <span v-if="formState.fsfycs" style="margin-right: 6px;">茶水</span>
                                                <span v-if="formState.fsfykqs" style="margin-right: 6px;">矿泉水</span>
                                                <span v-if="formState.fsfytq" style="margin-right: 6px;">台签</span>
                                                <span v-if="formState.fsfyyx">音响</span>
                                                <span
                                                    v-if="!formState.fsfycs&&!formState.fsfykqs&&!formState.fsfytq&&!formState.fsfyyx">
                                                    无
                                                </span>
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3">
                                        <span slot="label" class="descriptions-label-slot">
                                            设&emsp;&emsp;备
                                        </span>
                                        <a-form-item ref="fjbzbsc" prop="fjbzbsc" class="zm-form-model">
                                            <div v-if="linkName=='申请确认' || linkName == '数据修订'">
                                                <span style="margin-right: 10px;">
                                                    笔记本电脑:
                                                    <a-input-number
                                                        v-model="formState.fbjbdnyjt"
                                                        :defaultValue="formState.fbjbdnyjt"
                                                        :min="0"
                                                        class="number-input"/>
                                                </span>
                                                <span style="margin-right: 10px;">
                                                    投影仪:
                                                    <a-input-number
                                                        v-model="formState.ftyyyjt"
                                                        :defaultValue="formState.ftyyyjt"
                                                        :min="0"
                                                        class="number-input"/>
                                                </span>
                                                <span style="margin-right: 10px;">
                                                    有线话筒:
                                                    <a-input-number
                                                        v-model="formState.fyxhtyjz"
                                                        :defaultValue="formState.fyxhtyjz"
                                                        :min="0"
                                                        class="number-input"/>
                                                </span>
                                                <span>
                                                    无线话筒:
                                                    <a-input-number
                                                        v-model="formState.fwxhtyjz"
                                                        :defaultValue="formState.fwxhtyjz"
                                                        :min="0"
                                                        class="number-input"/>
                                                </span>
                                            </div>
                                            <span v-else>
                                                <span style="margin-right: 6px;">笔记本电脑: {{ formState.fbjbdnyjt }} 台；</span>
                                                <span style="margin-right: 6px;">投影仪: {{ formState.ftyyyjt }} 台；</span>
                                                <span style="margin-right: 6px;">有线话筒: {{ formState.fyxhtyjz }} 支；</span>
                                                <span style="margin-right: 6px;">无线话筒: {{ formState.fwxhtyjz }} 支；</span>
                                            </span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3">
                                        <span slot="label" class="descriptions-label-slot">
                                            会标内容
                                        </span>
                                        <a-form-item ref="fjbzbsc" prop="fjbzbsc" class="zm-form-model">
                                            <a-textarea
                                                v-if="linkName =='申请确认'||linkName == '数据修订'"
                                                v-model="formState.fhbnr"
                                                placeholder="请输入会标内容"
                                                :auto-size="{ minRows: 2}"/>
                                                <span v-else>{{ formState.fhbnr }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3">
                                        <span slot="label" class="descriptions-label-slot">
                                            备&emsp;&emsp;注
                                        </span>
                                        <a-form-item ref="fjbzbsc" prop="fjbzbsc" class="zm-form-model">
                                            <a-textarea
                                                v-if="linkName =='申请确认'||linkName == '数据修订'"
                                                v-model="formState.fbz"
                                                placeholder="请输入备注"
                                                :auto-size="{ minRows: 2}"/>
                                                <span v-else>{{ formState.fbz }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3" v-if="descriptionsData('科室审批').hjmc">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName == descriptionsData('科室审批').hjmc">*</span>
                                            科室领导意见
                                        </span>
                                        <a-form-item ref="fzbcsyj" prop="fzbcsyj" class="zm-form-model">
                                            <div style="width: 100%;" v-if="(descriptionsData('科室审批').blzt == '待办' && linkName!=='我的已办') || linkName == '数据修订'">
                                                <reviewOpinions
                                                    ref="reviewOpinionsReffzbcsyj"
                                                    @getInputOpinion="getInputOpinion"
                                                    @openOpinions="opinions('会议室',formState.fzbcsyj,'fzbcsyj')"
                                                    v-decorator="[
                                                        'fzbcsyj', { initialValue:formState.fzbcsyj, rules: rules.fzbcsyj}
                                                ]"/>
                                                <div  v-if="linkName == '数据修订'" style="text-align: right;">
                                                    <span>办理时间：</span>
                                                    <a-date-picker
                                                        show-time
                                                        :v-model="moment(formState.fzbcsyjsj)"
                                                        :default-value="moment(formState.fzbcsyjsj)"
                                                        :allowClear="false"
                                                        @change="yjTimeChange($event,'fzbcsyjsj')"
                                                    />
                                                </div>
                                            </div>
                                            <div style="width: 100%;" v-else>
                                                <p>{{ formState.fzbcsyj }}</p>
                                                <div class="yjqm-right-bottom">
                                                    <img v-if="getUrl('科室审批')" :src="getUrl('科室审批')" alt="" class="yjqmImg"/>
                                                    <span v-else class="yjqmImg">{{ formState.fzbcsyjr }}</span>
                                                    <span>{{ formState.fzbcsyjsj }}</span>
                                                </div>
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3" v-if="descriptionsData('办公室审批').hjmc">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName == descriptionsData('办公室审批').hjmc">*</span>
                                            办公室意见
                                        </span>
                                        <a-form-item ref="fbgsyj" prop="fbgsyj" class="zm-form-model">
                                            <div style="width: 100%;" v-if="(descriptionsData('办公室审批').blzt == '待办' && linkName!=='我的已办') || linkName == '数据修订'">
                                                <reviewOpinions
                                                    ref="reviewOpinionsReffbgsyj"
                                                    @getInputOpinion="getInputOpinion"
                                                    @openOpinions="opinions('会议室',formState.fbgsyj,'fbgsyj')"
                                                    v-decorator="[
                                                        'fbgsyj', { initialValue:formState.fbgsyj, rules: rules.fbgsyj}
                                                ]"/>
                                                <div  v-if="linkName == '数据修订'" style="text-align: right;">
                                                    <span>办理时间：</span>
                                                    <a-date-picker
                                                        show-time
                                                        :v-model="moment(formState.fbgsyjsj)"
                                                        :default-value="moment(formState.fbgsyjsj)"
                                                        :allowClear="false"
                                                        @change="yjTimeChange($event,'fbgsyjsj')"
                                                    />
                                                </div>
                                            </div>
                                            <div style="width: 100%;" v-else>
                                                <p>{{ formState.fbgsyj }}</p>
                                                <div class="yjqm-right-bottom">
                                                    <img v-if="getUrl('办公室审批')" :src="getUrl('办公室审批')" alt="" class="yjqmImg"/>
                                                    <span v-else class="yjqmImg">{{ formState.fbgsyjr }}</span>
                                                    <span>{{ formState.fbgsyjsj }}</span>
                                                </div>
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3" v-if="descriptionsData('会议安排').hjmc && linkName !== '数据修订'">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName == descriptionsData('会议安排').hjmc">*</span>
                                            会议安排
                                        </span>
                                        <a-form-item ref="fhyapyj" prop="fhyapyj" class="zm-form-model">
                                            <div style="width: 100%;" v-if="descriptionsData('会议安排').blzt == '待办' && linkName!=='我的已办'">
                                                <reviewOpinions
                                                    ref="reviewOpinionsReffhyapyj"
                                                    @getInputOpinion="getInputOpinion"
                                                    @openOpinions="opinions('会议室',formState.fhyapyj,'fhyapyj')"
                                                    v-decorator="[
                                                        'fhyapyj', { initialValue:formState.fhyapyj, rules: rules.fhyapyj}
                                                ]"/>
                                            </div>
                                            <div style="width: 100%;" v-else>
                                                <p>{{ formState.fhyapyj }}</p>
                                                <div class="yjqm-right-bottom">
                                                    <img v-if="getUrl('会议安排')" :src="getUrl('会议安排')" alt="" class="yjqmImg"/>
                                                    <span v-else class="yjqmImg">{{ formState.fhyapr }}</span>
                                                    <span>{{ formState.fhyapsj }}</span>
                                                </div>
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                </a-descriptions>
                            </a-form>
                        </a-spin>
                    </div>
                    <div v-if="summaryActiveKey == '流转记录'" style="padding-top: 30px;">
                        <transferRecords
                            ref="transferRecordsRef"
                            :config="circulationDataTableConfig"
                            @getCirculationQmImg="getCirculationQmImg"/>
                    </div>
                </div>
            </div>
            <template slot="footer">
                <div v-if="linkName == '我的已办'">
                    <a-button class="blue-btn" @click="closeVisible">关闭</a-button>
                </div>
                <div v-else-if="linkName == '会议安排'">
                    <a-button class="blue-btn" @click="onSubmit('提交')">确认会议安排</a-button>
                </div>
                <div v-else-if="linkName == '数据修订'">
                    <a-button class="blue-btn" @click="updataData">确认修订</a-button>
                </div>
                <div v-else>
                    <a-button @click="onSave('保存')">
                        保存
                    </a-button>
                    <a-button class="blue-btn" @click="onSubmit('提交')">
                        提交
                    </a-button>
                    <a-button v-if="linkName !== '申请确认'" class="red-btn" @click="returnClick">
                        退回
                    </a-button>
                </div>
            </template>
        </a-modal>
        <a-modal
            title="会议室详情"
            :visible="xiangqingVisible"
            width="50%"
            :footer="false"
            @cancel="xiangqingVisible = false"
            >
            <xiangQing></xiangQing>
        </a-modal>
        <printModal ref="printModalRef" />
    </div>
</template>
<script>
import {
    hysSfky,
    initBzFlow,
    saveFlow,
    submitFlow,
    queryJobByJobId,
    returnUpperzdyFlowJob,
    getMoreUserSignLinkList,
    pidgetlchj,
    editFuntion,
} from './service/index'
import assessCheckApi from './service/api.js'
import transferRecords from '../modal/transferRecords'
import printModal from '../modal/printModal'
import moment from 'moment'
import {typeSelect, typeCheckbox, } from '@/components/compSearchCriteria/ContractType'
import compSelector from '@/components/compSelector/compSelector'
import xiangQing from './meetingRoomDetails/index'
export default {
    components: {
        compSelector,
        transferRecords,
        printModal,
        xiangQing
    },
    data() {
        return {
            moment:moment,
            typeSelect:typeSelect,
            typeCheckbox:typeCheckbox,
            applicationFormVisible: false,
            summaryActiveKey: '申请表',
            aform:this.$form.createForm(this, { name: 'aform' }),
            formState: {
                fchry: 0,
                fwdwrys: 0,
                fwdwry: 0,
                fbjbdnyjt: 0,
                ftyyyjt: 0,
                fyxhtyjz: 0,
                fwxhtyjz: 0,
                fzxld: [],
            },
            timeForm: {
                rqDate: null,
                endDate: null,
                endTime: null,
            },
            circulationDataTableConfig: {
                api: assessCheckApi.flowJkPage,
                rowId: 'id',
                urlType: true,
                paramet:{
                    oaid: ''
                }
            },
            rules:{
                fhynr: [{
                    required: true,
                    message: '请输入会议内容',
                    trigger: 'blur',
                }],
                rqDate: [{
                    type: 'object',
                    required: true,
                    message: '请选择会议日期',
                    trigger: 'blur',
                }],
                startTime: [{
                    type: 'object',
                    required: true,
                    message: '请选择会议开始时间',
                    trigger: 'blur',
                }],
                endTime: [{
                    type: 'object',
                    required: true,
                    message: '请选择会议结束时间',
                    trigger: 'blur',
                }],
                fjbzbsy: [{
                    required: true,
                    message: '请输入会议室理由',
                    trigger: 'blur',
                }],
                fhydd: [{
                    type: 'array',
                    required: true,
                    message: '请选择会议地点',
                    trigger: 'blur',
                }],
                fksspr: [
                    { required: true, message: '请输入本科（室）意见', trigger: 'blur' }
                ],
                fbgspcyj: [
                    { required: true, message: '请输入办公室意见', trigger: 'blur' }
                ],
                ffgspr: [
                    { required: true, message: '请输入中心分管领导意见', trigger: 'blur' }
                ],
                fdwldspr: [
                    { required: true, message: '请输入中心主要领导意见', trigger: 'blur' }
                ],
            },
            compSelectorkey:null,
            qmImgList: [],
            displayList: [],
            linkName: '申请确认',
            spinning: false,
            xiangqingVisible: false,
        }
    },
    mounted() {
        // this.circulationDataTableConfig.paramet.oaid = '96db3fccad0245df878468d4339f9e5e'
        this.$refs.reviewOpinionsRef= Date.now()
    },
    methods: {
        getInitData(){
            this.summaryActiveKey = '申请表'
            this.formState = {}
            this.formState = {
                fchry: 0,
                fwdwrys: 0,
                fwdwry: 0,
                fbjbdnyjt: 0,
                ftyyyjt: 0,
                fyxhtyjz: 0,
                fwxhtyjz: 0,
                fzxld: [],
            }
        },
        getData(val){
            if(val){
                this.summaryActiveKey = '申请表'
                this.linkName = val.hjmc
                this.formState = {}
                this.formState = {
                    ...val.oaMap,
                    jobid: val.jobMap?val.jobMap.id:''
                }
                this.formState.fhydd = val.oaMap.fhydd?val.oaMap.fhydd.split(','):[]
                this.timeForm.rqDate = val.oaMap.fhykssj?moment(val.oaMap.fhykssj.substr(0,10)):null
                this.timeForm.startTime = val.oaMap.fhykssj?moment(val.oaMap.fhykssj.substr(11,5),'HH:mm'):null
                this.timeForm.endTime = val.oaMap.fhyjssj?moment(val.oaMap.fhyjssj.substr(11,5),'HH:mm'):null
                //console.log(this.timeForm.rqDate,this.timeForm.startTime,this.timeForm.endTime)
                this.formState.fhykssj = val.oaMap.fhykssj?moment(val.oaMap.fhykssj):null
                this.formState.fhyjssj = val.oaMap.fhyjssj?moment(val.oaMap.fhyjssj):null

                this.formState.fzxld = this.formState.fzxld?this.formState.fzxld.split(','):[]
                this.formState.fksdw = this.formState.fksdw?this.formState.fksdw.split(','):[]

                this.formState.fsfycs = this.formState.fsfycs== '是'?true:null,
                this.formState.fsfykqs = this.formState.fsfykqs== '是'?true:null,
                this.formState.fsfytq = this.formState.fsfytq== '是'?true:null,
                this.formState.fsfyyx = this.formState.fsfyyx== '是'?true:null,
                this.formState.fsfybjbdn = this.formState.fsfybjbdn== '是'?true:null,
                this.formState.fsfytyy = this.formState.fsfytyy== '是'?true:null,
                this.formState.fsfyyxht = this.formState.fsfyyxht== '是'?true:null,
                this.formState.fsfywxht = this.formState.fsfywxht== '是'?true:null,


                this.circulationDataTableConfig.paramet.oaid = this.formState.id
                this.qmImgList = []
                this.displayList = []
                this.getDisplayList()
            }
        },
        getDisplayList(){
            pidgetlchj({pid:this.formState.id}).then((res) => {
                let arr1 = res.result
                this.displayList = []
                this.displayList = res.result

                if(this.linkName == '数据修订'){
                    const index = this.displayList.findIndex((item) => item.blzt == '待办');
                    if (index !== -1) {
                        this.displayList.splice(index, 1);
                    }
                    //console.log('this.displayList',this.displayList)
                }

                arr1.forEach(async item => {
                    if(item.blrid && item.blzt!=='待办'){
                        let resa = await getMoreUserSignLinkList({ids:item.blrid})
                        if(resa.success && resa.result.length){
                            if(resa.result[0].signLink == ''){
                                // //console.log('没有获得图片 signLink == 0')
                                this.qmImgList.push({
                                    hjmc: item.hjmc,
                                    url: null
                                })
                            } else {
                                this.qmImgList.push({
                                    hjmc: item.hjmc,
                                    url: resa.result[0].signLink+'&aa='+Date.now()
                                })
                                // //console.log('获得的签名图片列表',this.qmImgList)
                            }
                        } else {
                            // //console.log('没有获得图片')
                        }
                    } else {}
                })
                // //console.log('最终获得的签名图片列表---',this.qmImgList)
            })
        },
        closeVisible(){
            this.applicationFormVisible = false
            this.$emit('success')
        },
        summaryActiveChange(val){
            //console.log(val)
        },
        startTimeChange(time,timeString){
            //console.log(time,timeString)
            /* 用日期方式转换回显会Invalid date，所以只能在使用时才用转format */
            this.timeForm.startTime = time?moment(time,'HH:mm'):null
        },
        endTimeChange(time,timeString){
            //console.log(time,timeString)
            this.timeForm.endTime = time?moment(time,'HH:mm'):null
        },
        fhyddChange(val){
            //console.log('fhyddChange',val)
            this.formState.fhydd = val
            this.aform.setFieldsValue({
                fhydd: [val],
            });
        },
        fzxldChange(val){
            //console.log(val)
            this.formState.fzxld = val
            this.aform.setFieldsValue({
                fzxld: [val],
            });
        },
        timeFormValue(){
            if(this.timeForm.rqDate&&this.timeForm.startTime&&this.timeForm.endTime){
                return true
            } else {
                return false
            }
        },
        // 查询会议室是否可用
        searchUse(){
            if(this.timeFormValue() && this.formState.fhydd){
                let data = {
                    fhykssj: moment(this.timeForm.rqDate).format('YYYY-MM-DD') + ' ' + moment(this.timeForm.startTime).format('HH:mm'),
                    fhyjssj: moment(this.timeForm.rqDate).format('YYYY-MM-DD') + ' ' + moment(this.timeForm.endTime).format('HH:mm'),
                    fhydd: this.formState.fhydd,
                    id: this.formState.id?this.formState.id:null
                }
                hysSfky(data).then(res => {
                    if(res.code == 200){
                    this.$message.success(res.message)
                    } else {
                    this.$message.warning(res.message)
                    }
                })
            } else {
                this.$message.warning('查询某会议室是否可用前，请先填写完整会议地点,会议日期，会议开始时间，会议结束时间。')
            }
        },
        // 会议室详情
        roomXiangQing(){
            this.xiangqingVisible = true
        },
        selectHandleChange(val){
            //console.log('selectHandleChange',val)
            this.formState.fksdw = val
            this.aform.setFieldsValue({
                fksdw: [val],
            });
        },
        getCirculationQmImg(item1,item2){
            //console.log('-----?????-----',item1,item2)
            this.qmImgList = []
            this.displayList = []
            this.qmImgList = item1
            this.displayList = [...item2]
            //console.log('111111111',this.qmImgList)
            //console.log('222222222',this.displayList)
        },
        getUrl(hjmcName){
            let url = ''
            //console.log('没有？？？',this.qmImgList)
            this.qmImgList.forEach(item => {
                //console.log(hjmcName,item)
                if(item.hjmc == hjmcName){
                    url = item.url
                }
            })
            //console.log(hjmcName,url)
            return url
        },
        descriptionsData(hjmc){
            let data = {}
            this.displayList.forEach(item => {
                //console.log('descriptionsData000',hjmc,item)
                if(item.hjmc == hjmc){
                    data = {...item}
                }
            })
            //console.log('descriptionsData',data)
            return data
        },
        getInputOpinion(val,valueData){
            //console.log(val,valueData)
            let data = this.formState
            data[valueData.hjmc] = val
            this.aform.setFieldsValue({
                fksspr: this.formState.fksspr,
                fbgspcyj: this.formState.fbgspcyj,
                ffgspr: this.formState.ffgspr,
                fdwldspr: this.formState.fdwldspr
            });
        },
        opinions(val1,val2,val3){
            //console.log(val1,val2,val3)
            this.$refs[`reviewOpinionsRef${val3}`].getData({opinionType:val1,oldVal:val2,valueData:{hjmc:val3}})
        },
        onSave(){
            let data = {}
            let sdata = {
                jobid: this.formState.jobid,
                oaid: this.formState.id,
                map: {},
                opinion: '',
            }
            if(this.linkName == '申请确认'){
                data = {
                    fhynr: this.formState.fhynr,
                    fhydd: this.formState.fhydd.toString(),
                    fhykssj: this.timeForm.rqDate?(moment(this.timeForm.rqDate).format('YYYY-MM-DD') + ' ' + moment(this.timeForm.startTime).format('HH:mm')):'',
                    fhyjssj: this.timeForm.rqDate?(moment(this.timeForm.rqDate).format('YYYY-MM-DD') + ' ' + moment(this.timeForm.endTime).format('HH:mm')):'',
                    fksdw: this.formState.fksdw?this.formState.fksdw.toString():'',
                    fzxld: this.formState.fksdw?this.formState.fzxld.toString():'',
                    fchry: this.formState.fchry,
                    fwdwry: this.formState.fwdwry,
                    fwdwrys: this.formState.fwdwrys,
                    fbz: this.formState.fbz,
                    fhbnr: this.formState.fhbnr,
                    fsfycs: this.formState.fsfycs== true?'是':null,
                    fsfykqs: this.formState.fsfykqs== true?'是':null,
                    fsfytq: this.formState.fsfytq== true?'是':null,
                    fsfyyx: this.formState.fsfyyx== true?'是':null,
                    fsfybjbdn: (this.formState.fbjbdnyjt&&this.formState.fbjbdnyjt > 0)?'是':null,
                    fsfytyy: (this.formState.ftyyyjt&&this.formState.ftyyyjt > 0)?'是':null,
                    fsfyyxht: (this.formState.fyxhtyjz&&this.formState.fyxhtyjz > 0)?'是':null,
                    fsfywxht: (this.formState.fwxhtyjz&&this.formState.fwxhtyjz > 0)?'是':null,
                    fbjbdnyjt: this.formState.fbjbdnyjt,
                    ftyyyjt: this.formState.ftyyyjt,
                    fwxhtyjz: this.formState.fwxhtyjz,
                    fyxhtyjz: this.formState.fyxhtyjz,
                    id: this.formState.id?this.formState.id:''
                }
                sdata.map = {
                    ...data
                }
                this.formState.id?this.saveFlowFuntion(sdata):this.initBzFlowFuntion(data)
            } else if(this.linkName == '科室审批'){
                sdata.map = {
                    fzbcsyj: this.formState.fzbcsyj,
                    fzbcsyjr: this.formState.fzbcsyjr,
                    fzbcsyjsj: this.formState.fzbcsyjsj,
                    fzbcsyjrks: this.formState.fsyks,
                }
                sdata.opinion = this.formState.fzbcsyj,
                this.saveFlowFuntion(sdata)
            } else if(this.linkName == '办公室审批'){
                sdata.map = {
                    fbgsyj: this.formState.fbgsyj,
                    fbgsyjr: this.formState.fbgsyjr,
                    fbgsyjrks: this.formState.fbgsyjrks,
                    fbgsyjsj: this.formState.fbgsyjsj
                }
                sdata.opinion = this.formState.fbgsyj,
                this.saveFlowFuntion(sdata)
            }
        },
        onSubmit(){
            this.aform.validateFields((err, values) => {
                if (!err) {
                    var that = this
                    that.$confirm({
                        title: '您确定要提交吗?',
                        onOk() {
                            let data = {
                                jobid: that.formState.jobid,
                                oaid: that.formState.id,
                                map: {},
                                opinion: '',
                            }
                            if(that.linkName == '申请确认'){
                                data.map = {
                                    fhynr: that.formState.fhynr,
                                    fhydd: that.formState.fhydd.toString(),
                                    fhykssj: that.timeForm.rqDate?(moment(that.timeForm.rqDate).format('YYYY-MM-DD') + ' ' + moment(that.timeForm.startTime).format('HH:mm')):'',
                                    fhyjssj: that.timeForm.rqDate?(moment(that.timeForm.rqDate).format('YYYY-MM-DD') + ' ' + moment(that.timeForm.endTime).format('HH:mm')):'',
                                    fksdw: that.formState.fksdw?that.formState.fksdw.toString():'',
                                    fzxld: that.formState.fksdw?that.formState.fzxld.toString():'',
                                    fchry: that.formState.fchry,
                                    fwdwry: that.formState.fwdwry,
                                    fwdwrys: that.formState.fwdwrys,
                                    fbz: that.formState.fbz,
                                    fhbnr: that.formState.fhbnr,
                                    fsfycs: that.formState.fsfycs== true?'是':null,
                                    fsfykqs: that.formState.fsfykqs== true?'是':null,
                                    fsfytq: that.formState.fsfytq== true?'是':null,
                                    fsfyyx: that.formState.fsfyyx== true?'是':null,
                                    fsfybjbdn: (that.formState.fbjbdnyjt&&that.formState.fbjbdnyjt > 0)?'是':null,
                                    fsfytyy: (that.formState.ftyyyjt&&that.formState.ftyyyjt > 0)?'是':null,
                                    fsfyyxht: (that.formState.fyxhtyjz&&that.formState.fyxhtyjz > 0)?'是':null,
                                    fsfywxht: (that.formState.fwxhtyjz&&that.formState.fwxhtyjz > 0)?'是':null,
                                    fbjbdnyjt: that.formState.fbjbdnyjt,
                                    ftyyyjt: that.formState.ftyyyjt,
                                    fwxhtyjz: that.formState.fwxhtyjz,
                                    fyxhtyjz: that.formState.fyxhtyjz,
                                    id: that.formState.id?that.formState.id:'',
                                    fsffqlc: that.formState.id?'':'是',
                                }
                                that.formState.id?that.submitFlowFuntion(data):that.initBzFlowFuntion(data.map,'1')
                            } else if(that.linkName == '科室审批'){
                                data.map = {
                                    fzbcsyj: that.formState.fzbcsyj,
                                    fzbcsyjr: that.formState.fzbcsyjr,
                                    fzbcsyjsj: that.formState.fzbcsyjsj,
                                    fzbcsyjrks: that.formState.fsyks,
                                }
                                data.opinion = that.formState.fzbcsyj,
                                that.submitFlowFuntion(data)
                            } else if(that.linkName == '办公室审批'){
                                data.map = {
                                    fbgsyj: that.formState.fbgsyj,
                                    fbgsyjr: that.formState.fbgsyjr,
                                    fbgsyjrks: that.formState.fbgsyjrks,
                                    fbgsyjsj: that.formState.fbgsyjsj
                                }
                                data.opinion = that.formState.fbgsyj,
                                that.submitFlowFuntion(data)
                            } else if(that.linkName == '会议安排'){
                                data.map = {
                                    fhyapr: that.formState.fhyapr,
                                    fhyapsj: that.formState.fhyapsj,
                                    fhyapyj: '同意会议安排',
                                    fhyapks: that.formState.fhyapks
                                }
                                data.opinion = '同意会议安排',
                                that.submitFlowFuntion(data)
                            }
                        },
                        onCancel() {},
                    });
                }
            })
        },
        initBzFlowFuntion(data,type){
            initBzFlow(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.formState = {}
                    this.formState = {
                        ...res.result.oaMap,
                        jobid: res.result.jobMap.id
                    }
                    this.formState.fhydd = this.formState.fhydd?this.formState.fhydd.split(','):[]
                    this.timeForm.rqDate = moment(this.formState.fhykssj.substr(0,10))
                    this.timeForm.startTime = moment(this.formState.fhykssj.substr(11,5),'HH:mm')
                    this.timeForm.endTime = moment(this.formState.fhyjssj.substr(11,5),'HH:mm')
                    //console.log(this.timeForm.rqDate,this.timeForm.startTime,this.timeForm.endTime)
                    this.formState.fhykssj = moment(this.formState.fhykssj)
                    this.formState.fhyjssj = moment(this.formState.fhyjssj)
                    if(type){
                        this.closeVisible()
                    }
                } else {
                    this.$message.warning(res.message)
                }
                this.loading = false
            })
        },
        saveFlowFuntion(data){
            this.spinning = true
            saveFlow(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                } else {
                    this.$message.warning(res.message)
                }
                this.spinning = false
            })
        },
        submitFlowFuntion(data){
            this.spinning = true
            submitFlow(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.closeVisible()
                } else {
                    this.$message.warning(res.message)
                }
                this.spinning = false
            })
        },
        // 退回
        returnClick(){
            this.aform.validateFields((err, values) => {
                if (!err) {
                    var that = this
                    that.$confirm({
                        title: '您确定要退回吗?',
                        onOk() {
                            that.spinning = true
                            queryJobByJobId({jobid:that.formState.jobid}).then(res => {
                                let list = res.result.jobHistoryList
                                let slist = list.filter(item => item.fhjmc == '申请确认')
                                const sortedDates = slist.sort((a, b) => new Date(b) - new Date(a));
                                that.returnFuntion(that.formState.jobid,sortedDates[slist.length - 1].id)
                            })
                        },
                        onCancel() {},
                    })
                }
            })
        },
        returnFuntion(jobid,ids){
            let returnStr = ''
            if(this.linkName == '申请确认'){
                returnStr = this.formState.fksshyj
            } else if(this.linkName == '科室审批'){
                returnStr = this.formState.fksspr
            } else if(this.linkName == '分管审批'){
                returnStr = this.formState.ffgspr
            } else if(this.linkName == '单位领导审批'){
                returnStr = this.formState.fdwldspr
            }
            let data = {
                jobid: jobid,
                opinion: returnStr,
                shjid: ids,
                lcmbbm: '',
                smgflag: '',
                smsContent: '',
            }
            returnUpperzdyFlowJob(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.closeVisible()
                } else {
                    this.$message.error(res.message)
                }
                this.spinning = false
            })
        },
        printClick(type,value,qmValue){
            this.$refs.printModalRef.modalClick(type,value,qmValue)
        },
        yjTimeChange(val,name){
            let data = this.formState
            data[name] = moment(val).format('YYYY-MM-DD HH:mm:ss')
        },
        updataData(){
            var that = this
            that.$confirm({
                title: '您确定修改当前表单数据吗?',
                onOk() {
                    let data = {
                        id: that.formState.id,
                        fhynr: that.formState.fhynr,
                        fhydd: that.formState.fhydd.toString(),
                        fhykssj: that.timeForm.rqDate?(moment(that.timeForm.rqDate).format('YYYY-MM-DD') + ' ' + moment(that.timeForm.startTime).format('HH:mm')):'',
                        fhyjssj: that.timeForm.rqDate?(moment(that.timeForm.rqDate).format('YYYY-MM-DD') + ' ' + moment(that.timeForm.endTime).format('HH:mm')):'',
                        fksdw: that.formState.fksdw?that.formState.fksdw.toString():'',
                        fzxld: that.formState.fksdw?that.formState.fzxld.toString():'',
                        fchry: that.formState.fchry,
                        fwdwry: that.formState.fwdwry,
                        fwdwrys: that.formState.fwdwrys,
                        fbz: that.formState.fbz,
                        fhbnr: that.formState.fhbnr,
                        fsfycs: that.formState.fsfycs== true?'是':null,
                        fsfykqs: that.formState.fsfykqs== true?'是':null,
                        fsfytq: that.formState.fsfytq== true?'是':null,
                        fsfyyx: that.formState.fsfyyx== true?'是':null,
                        fsfybjbdn: (that.formState.fbjbdnyjt&&that.formState.fbjbdnyjt > 0)?'是':null,
                        fsfytyy: (that.formState.ftyyyjt&&that.formState.ftyyyjt > 0)?'是':null,
                        fsfyyxht: (that.formState.fyxhtyjz&&that.formState.fyxhtyjz > 0)?'是':null,
                        fsfywxht: (that.formState.fwxhtyjz&&that.formState.fwxhtyjz > 0)?'是':null,
                        fbjbdnyjt: that.formState.fbjbdnyjt,
                        ftyyyjt: that.formState.ftyyyjt,
                        fwxhtyjz: that.formState.fwxhtyjz,
                        fyxhtyjz: that.formState.fyxhtyjz,
                        fzbcsyj: that.formState.fzbcsyj,
                        fzbcsyjr: that.formState.fzbcsyjr,
                        fzbcsyjsj: that.formState.fzbcsyjsj,
                        fzbcsyjrks: that.formState.fsyks,
                        fbgsyj: that.formState.fbgsyj,
                        fbgsyjr: that.formState.fbgsyjr,
                        fbgsyjrks: that.formState.fbgsyjrks,
                        fbgsyjsj: that.formState.fbgsyjsj
                    }
                    //console.log(data)
                    that.spinning = true
                    editFuntion(data).then(res => {
                        if(res.code == 200){
                            that.$message.success(res.message)
                        } else {
                            that.$message.warning(res.message)
                        }
                        that.spinning = false
                    })
                },
                onCancel() {
                    //console.log('Cancel');
                },
            });
        },
    }
}
</script>
<style>
@import url('../css/oaLess.css');
</style>
